import {Schema, type} from "@colyseus/schema";
import {ArraySchema} from "@colyseus/schema/lib/types/ArraySchema";
import {GameObject2D} from "./GameObject";

export class Bullet extends GameObject2D {

    @type("number")
    speed: number = 20;

    @type("number")
    damage: number = 20;

    constructor() {
        super();
        this.x = 0;
        this.x = 0;
        this.w = 5;
        this.h = 5;
    }
}

export class Player extends GameObject2D {

    @type("string")
    name: string = "";

    // 0 △ 1 <- 2 ▽ 3 ->
    @type("number")
    dir: number = 2;

    @type("number")
    speed: number = 10;

    @type("string")
    color: string = "";

    @type("number")
    hp: number = 100;

    @type("boolean")
    active: boolean = true;

    // 子弹组
    @type([Bullet])
    bullets = new ArraySchema<Bullet>();

    constructor() {
        super();
        this.x = 10;
        this.y = 10;
        this.w = 50;
        this.h = 50;
    }
}